/**
 * 
 */
package com.shop.cloud.domain.hongfu;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author 作者姓名 E-mail: email地址
 * @version 创建时间：2018年1月2日 上午11:53:18
 * 类说明
 */
/**
 * @author Administrator
 *
 */
public class ListToMap {
	private Map map;
	 public ListToMap()
	 {
	  map = new HashMap();
	 }
	 public void createClass(String className, String id, String name)
	 {
	  Map subMap = (Map)map.get(className);
	  if (subMap == null)
	  { subMap = new HashMap();
	   map.put(className, subMap);  //已经存在班级，只需要向学生这个Map集合里边存数据，而班级的Map不需要再存了
	  }
	  subMap.put(id, name);
	 }
	 
	 
	 public String getName(String className, String id)
	 {  
	  Map subMap = (Map)map.get(className);
	  return (String)subMap.get(id);
	 }
	 
	 public void getStudent(String className)
	 { 
	  System.out.println(className);
	  Map subMap = (Map)map.get(className);
	  Set mySet = subMap.keySet();
	  for (Iterator it = mySet.iterator(); it.hasNext(); )
	  {
	   String id = (String)it.next();
	   String name = (String)subMap.get(id);
	   System.out.println(id + "..." + name);
	  }
	 }
	 public Map<String,List> getAll()
	 {  
	  Map<String,List> map2 = new HashMap<String,List>();
	  Set set1 = map.keySet();
	  for (Iterator it = set1.iterator(); it.hasNext(); )
	  {
	   String className = (String)it.next();
//	   System.out.println(className);
	   Map subMap = (Map)map.get(className);
	   Set set2 = subMap.keySet();
	   
	   List<String> list=new ArrayList<String>();
	   for (Iterator it1 = set2.iterator(); it1.hasNext(); )
	   {
	    String id = (String)it1.next();
	    String name = (String)subMap.get(id);
//	    System.out.println(it + "..." + name);
	    list.add(name);
	    map2.put(className, list);
	   }
	   
	 
	  }
	  return map2;
	 }
}
